package com.bangyu.monitor.modular.system.entity;

import com.bangyu.monitor.core.common.constant.Const;
import com.bangyu.monitor.core.common.constant.ConstantEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.apache.commons.lang.time.DateFormatUtils;

import java.util.Date;

/**
 * @Auther: zhangxue
 * @Date: 19/4/18 18:58
 * @Description:
 */
@Data
@TableName("sys_risk")
public class Risk {

    private Long id;
    private Long bridgeId;
    private String bridgeName;
    private String beamNo;
    private Integer riskLevel;
    private Integer riskType;
    private long riskTime;//报警时间
    private Integer riskDate;
    private long payloadTime;//荷载时间
    private String detail;


    public Risk buildBridgeId(Long bridgeId){
     this.bridgeId = bridgeId;
     return this;
    }

    public Risk buildBridgeName(String bridgeName){
        this.bridgeName = bridgeName;
        return this;
    }
    public Risk buildBeamNo(String beamNo){
        this.beamNo = beamNo;
        return this;
    }
    public Risk buildRiskLevel(Integer riskLevel){
        this.riskLevel = riskLevel;
        return this;
    }

    public Risk buildRiskType(Integer riskType){
        this.riskType = riskType;
        return this;
    }
    public Risk buildRiskTime(long riskTime){
        this.riskTime = riskTime;
        this.riskDate = Integer.parseInt(DateFormatUtils.format(riskTime,"yyyyMMdd"));
        return this;
    }
    public Risk buildPayloadTime(long payloadTime){
        this.payloadTime = payloadTime;
        return this;
    }
    public Risk buildDetial(String detail){
        this.detail = detail;
        return this;
    }

    public String toString(){
        StringBuilder sb = new StringBuilder("桥梁id:");
        sb.append(this.bridgeId)
                .append(" 桥梁名称:")
                .append(this.bridgeName)
                .append(" 梁编号:")
                .append(this.beamNo)
                .append(" 荷载发生时间")
                .append(this.payloadTime)
                .append(" 报警时间")
                .append(this.riskType)
                .append(" 报警级别:")
                .append(this.riskLevel)
                .append(" 警报类别:")
                .append(ConstantEnum.RiskType.getName(this.getRiskType()))
                .append(" 详情")
                .append(this.detail);
        return sb.toString();
    }


}
